#coding: utf-8

from fabric.api import *

def exists(path, prefix=run, verbose=False):
    """
    Return True if given path exists on targeted host.
    """
    func = prefix and local or sudo or run
    cmd = 'test -e "%s"' % path
    if verbose:
        with settings(warn_only=True):
            return not func(cmd).failed
    # Otherwise, be quiet
    with settings(hide('everything'), warn_only=True):
        return not func(cmd).failed